# AUTHOR: DING
# -*- codeing = utf-8 -*-
# @Time: 2024/2/29 11:28
# @Author: 86139
# @Site: 
# @File: 21-save.py
# @Software: PyCharm
# tensorboard --logdir=pytorch/logs --port=6007
import torch
import torchvision

vgg16 = torchvision.models.vgg16(pretrained=False)
# 保存方式1
torch.save(vgg16,"vgg_method1.pth")
model1 = torch.load("vgg_method1.pth")
print(model1)

# 保存方式2：保存参数(官方推荐，节约空间)
torch.save(vgg16.state_dict(),"vgg_method2.pth")
vgg16_2 = torchvision.models.vgg16(pretrained = False)
vgg16_2.load_state_dict(torch.load("vgg_method2.pth"))
print(vgg16_2)